package com.cocotea.example.aop;

import com.cocotea.context.AutoValidStarterContext;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Aspect
public class ValidAop {
    @Resource
    private AutoValidStarterContext autoValidStarterContext;

    @Pointcut("execution(public * com.cocotea.example.controller.*.*(..))")
    public void pointCut() {
    }

    @Around("pointCut()")
    public Object methodAround(ProceedingJoinPoint pjp) throws Throwable {
        return autoValidStarterContext.cut(pjp);
    }
}
